home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / libsrc~1.z / libsrc~1 / bzero.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-28  |  598 b   |  37 lines

  1. #include "lib.h"
  2.  
  3. #define ODD(x) (((short)(x)) & 1)    /* word ops are faster */
  4.  
  5. /*
  6.  * zero out a chunk efficiently
  7.  * handles odd address
  8.  *
  9.  *   ++jrb  bammi@dsrgsun.ces.cwru.edu
  10.  */
  11. void bzero(b, n)
  12. register _VOIDSTAR b;
  13. register long n;
  14. {
  15.     register long l, w;
  16.     
  17.     
  18.     if(ODD(b))
  19.     {
  20.     *(char *)b++ = (char)0;
  21.     n--;
  22.     }
  23.  
  24.     l = (n >> 2); /* # of longs */
  25.     n -= (l << 2);
  26.     w = (n >> 1); /* # of words */
  27.     n -= (w << 1); /* n == # of residual bytes */
  28.  
  29.     while(l--)
  30.     *((long *)b)++ = 0L;
  31.     while(w--)
  32.     *((short *)b)++ = (short)0;
  33.     while(n--)
  34.     *(char *)b++ = (char)0;
  35. }
  36.  
  37.